/**
 * Created by luqidong on 2018/1/12.
 */
const Log = function() {};

/**
 * 写普通日志
 * @param {String} title
 * @param {String} context
 * @param {String} level
 * @param {Object} tags
 */
Log.writeNormalLog = function(title='',context='',level='info',tags={}) {
    Raven.captureMessage(title,{level,tags,extra:{context}});
};

/**
 * 写异常日志
 * @param {String} ex
 * @param {String} context
 * @param {String} level
 * @param {Object} tags
 */
Log.writeExLog = function(ex,context='',level='info',tags={}) {
    Raven.captureException(ex,{level,tags,extra:{context}});
};


Log.Level={
    INFO:'info',
    WARNING:'warning',
    ERROR:'error'
};

export default {
    /**
     * Raven.js 日志记录插件
     * Doc:https://docs.sentry.io/clients/javascript/usage/
     * @param {*} Vue
     * @param {Object} options
     */
    install(Vue, options = {}) {
        Raven.config("your dsn")
            .addPlugin(RavenVue, Vue)
            .install();

        Raven.setUserContext({
            user: options.user || ""
        });

        Raven.setTagsContext({ environment: options.env });

        Object.defineProperties(Vue.prototype, {
            $log: { value: Log, writable: true }
        });
    }
};